var reviveCount = -100;
var mapIds = [800024480];
var 准备地图 = 800024004;
var eventName = "蘑菇神社_记忆试炼2";

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance(eventName);
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully()
    }
    return c
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(1000 * 60 * 5)
}

function 刷怪(a) {
    var c = a.getMapInstance(0);
    while (c.countMonsterById(9400061, 9400073) < 25) {
        var b = em.getMonster(9400073);
        b.setSize(a.rand(100, 250));
        c.spawnMonsterOnGroundBelow(b, new java.awt.Point(a.rand(-449, 1421), -28))
    }
}

function 提示1(a) {
    a.getPlayers().forEach(function (b) {
        b.getAPI().effect_NormalSpeechBalloon("......", 1, 0, 0, 2000, 1, 0, 0, 0, 4, 9112018, null, b.getId())
    })
}

function 提示2(a) {
    a.getPlayers().forEach(function (b) {
        b.getAPI().effect_NormalSpeechBalloon("……被私心和嫉妒迷了眼的人们啊……", 1, 0, 0, 2000, 1, 0, 0, 0, 4, 9112018, null, b.getId())
    })
}

function 提示3(a) {
    a.getPlayers().forEach(function (b) {
        b.getAPI().effect_NormalSpeechBalloon("……我比任何人都更遵从佛家的教诲……", 1, 0, 0, 3000, 1, 0, 0, 0, 4, 9112018, null, b.getId())
    })
}

function 提示4(a) {
    a.getPlayers().forEach(function (b) {
        b.getAPI().effect_NormalSpeechBalloon("最终却落得如此悲惨的下场，不可原谅。", 1, 0, 0, 3000, 1, 0, 0, 0, 4, 9112018, null, b.getId())
    })
}

function 提示5(a) {
    a.getPlayers().forEach(function (b) {
        b.getAPI().effect_NormalSpeechBalloon("……可恶的人类！！！！！", 1, 0, 0, 3000, 1, 0, 0, 0, 4, 9112018, null, b.getId())
    })
}

function 完成(a) {
    a.getPlayers().forEach(function (b) {
        b.getAPI().openNpc("蘑菇神社_记忆试炼2_通过")
    })
}

function onPlayerRevived(b, a) {
    return false
}

function onMonsterKilled(b, d) {
    var c = em.getNumberProperty("state");
    var e = 16;
    var a = em.getNumberProperty("stage" + c + "_kill") + 1;
    em.setProperty("stage" + c + "_kill", a)
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    switch (a) {
        case 302050100:
            initProp("stage" + 1 + "_kill", 0);
            break;
        case 302050200:
            initProp("stage" + 1 + "_kill", 0);
            break;
        case 302050300:
            initProp("stage" + 1 + "_kill", 0);
            break
    }
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function openNpc(c, b, d) {
    for (var a = 0; a < c.getPlayerCount(); a++) {
        c.getPlayers().get(a).getAPI().openNpc(b, d)
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};